home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 3.2
/
Ham Radio Version 3.2 (Chestnut CD-ROMs)(1993).ISO
/
packet
/
bpq405
/
external.doc
< prev
next >
Wrap
Text File
|
1992-03-22
|
5KB
|
302 lines
The switch now contains code to support external Hardware Drivers.
The following is an outline spec of the interface. This feature is still
under development - any comments from potential users would be appreciated.
The driver is called by a software interrupt, and must be loaded before
the switch. Each driver can support multiple channels, and more than one
driver may be loaded, so long as each has its own software interrupt number.
At the moment the driver supplies only the Level 1 funtions, ie it effectively
provides a KISS-like interface. Later I hope to support external Level 2
drivers as well.
The transmit buffer will have a 5 byte header, with the length in 4th and
5th bytes. The length includes the header. The received frame passed to
the switch should have the same format.
; THE ROUTINE IS CALLED VIA A SIMULATED INT, SO SHOULD RETURN
; WITH AN IRET. THE DRIVER MAY SUPPORT MULTIPLE LOGICAL CHANNELS -
; THE CHANNEL NUMBER IS PASSED IN AL
;
; THE ROUTINE MUST PRESERVE ALL SEGMENT REGISTERS, UNLESS USED TO
; RETURN A VALUE (IE DS IN FUNCTION 1). OTHER REGISTERS NEED NOT BE
; SAVED
;
; THE ROUTINE MUST PROVIDE THE FOLLOWING FUNCTIONS:
;
;
; AH=0 INITIALISE. CALLED ONCE ON LOAD
;
; AH=1 RETURNS POINTER TO RECEIVED FRAME IN DS:SI, LENGTH IN CX
; RETURNS CX=0 IF NO FRAME READY
;
; AH=2 SEND FRAME IN BUFFER IN DS:DI - LENGTH IS IN WORD AT 3[DI]
; DATA FOLLOWS LENGTH
;
; AH=3 STATUS. RETURNS AX=0 IF TX NOT BUSY. CX=0 IF RX NOT READY
;
The driver does not need to queue transmitted frames, but performance is
likely to be improved if it can buffer a reasonable number of frames. The
receive process must always be capable of buffering frames.
John Wiseman, G8BPQ
9/2/92
The following sample code is equivalent to the INTERNAL Loopback
driver - ie anything sent to it is received.
PAGE 62,132
;
CODE SEGMENT PUBLIC 'CODE'
ASSUME CS:CODE,DS:CODE,ES:CODE
;
; INTERFACE TO SWITCH IS VIA SOFTWARE INTERRUPT
;
; COMMANDS SUPPORTED ARE:
;
; SUBCHANNEL IS IN AL
;
; AH = 0 INIT Driver
;
; AH = 1 Poll for data. Returns CX = 0 if none available,
; otherwise CX=length, DS:SI=Data
;
; AH = 2 Send frame. DS:DI = Buffer header.
;
; AH = 3 Status - Return AX=0 If OK to send a frame.
; CX=0 If no frame available to receive
;
ORG 100H
GO:
JMP INIT
SWITCHINT:
CMP AH,3
JE STATUS
CMP AH,2
JE PUTFRAME
CMP AH,1
JE POLL
IRET
STATUS:
MOV AX,0
CMP CS:FRAMEFLAG,0 ; TX BUSY?
JZ STAT00 ; NO
MOV AX,1
STAT00:
CMP CS:FRAMEFLAG,0 ; RX READY?
JE POLLRET ; NO
MOV CX,1
IRET
POLL:
CMP CS:FRAMEFLAG,0
JE POLLRET
PUSH CS
POP DS
MOV SI,OFFSET FRAMECOPY
MOV CX,3[SI]
MOV FRAMEFLAG,0
IRET
POLLRET:
MOV CX,0
IRET
PUTFRAME:
PUSH SI
PUSH DI
PUSH CX
PUSH ES ; save regs
MOV CX,3[DI]
MOV SI,DI
MOV DI,OFFSET FRAMECOPY
MOV CS:FRAMEFLAG,1
PUSH CS
POP ES ; ES TO OUR SEGMENT
REP MOVSB ; SAVE FRAME
POP ES
POP CX
POP DI
POP SI
IRET
FRAMECOPY DB 400 DUP (0)
FRAMEFLAG db 0
ENDOFCODE LABEL BYTE
MSG DB 'Sample EXTERNAL Interface for G8BPQ switch '
db 0dh,0ah,'$'
ERRORMSG DB 0AH,'Parameter error:',0dh,0ah,0ah
db 'Format is DRIVER interrupt'
db 0dh,0ah,'Program NOT installed'
DB 0dh,0ah,0AH,'$'
INIT:
MOV DX,OFFSET MSG
MOV AH,9
INT 21H
;
MOV SI,82H ; PARAM STRING
CALL GETVALUE ; interrupt number
JC BADPORTVAL
MOV AL,BYTE PTR NEWVALUE
OR AL,AL
JZ BADPORTVAL
;
MOV AL,BYTE PTR NEWVALUE ; VECTOR
MOV DX,OFFSET SWITCHINT
MOV AH,25H
INT 21H ; SET VECTOR
;
MOV DX,OFFSET ENDOFCODE
INT 27H
BADPORTVAL:
MOV AH,9
MOV DX,OFFSET ERRORMSG
INT 21H
RET
NEWVALUE DW 0
D16 DW 16
D10 DW 10
GETVALUE:
;
; EXTRACT NUMBER (HEX OR DECIMAL) FROM INPUT STRING
;
MOV NEWVALUE,0
LODSB
CMP AL,'$' ; HEX?
JE DECODEHEX
DEC SI
VALLOOP:
LODSB
CMP AL,' '
JE ENDVALUE
CMP AL,0DH
JE ENDVALUE
CMP AL,','
JE ENDVALUE
;
; ANOTHER DIGIT - MULTIPLY BY 10
;
MOV AX,NEWVALUE
MUL D10
MOV NEWVALUE,AX
MOV AL,-1[SI]
SUB al,'0'
JC DUFFVALUE
CMP AL,10
JNC DUFFVALUE
MOV AH,0
ADD NEWVALUE,AX
JC DUFFVALUE
JMP VALLOOP
DECODEHEX:
HEXLOOP:
LODSB
CMP AL,' '
JE ENDVALUE
CMP AL,0DH
JE ENDVALUE
CMP AL,','
JE ENDVALUE
;
; ANOTHER DIGIT - MULTIPLY BY 16
;
MOV AX,NEWVALUE
MUL D16
MOV NEWVALUE,AX
MOV AL,-1[SI]
SUB al,'0'
JC DUFFVALUE
CMP AL,10
JC HEXOK
SUB AL,7
CMP AL,10
JC DUFFVALUE
CMP AL,16
JNC DUFFVALUE
HEXOK:
MOV AH,0
ADD NEWVALUE,AX
JMP HEXLOOP
ENDVALUE:
CLC
RET
DUFFVALUE:
STC
RET
CODE ENDS
;
END GO
John Wiseman, G8BPQ
21/3/92